package com.example.springbootradisjedisdemo;
import com.example.springbootradisjedisdemo.bean.UserEntity;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.RestController;

import java.io.Serializable;

@SpringBootTest
public class SpringbootRedisDemoApplicationTests {
    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @Test
    public void testSet(){
        stringRedisTemplate.boundValueOps("name").set("zhangsan");
        UserEntity userEntity = new UserEntity();
        userEntity.setId(1L);
        userEntity.setUserName("lishi");
        stringRedisTemplate.boundValueOps("name").set(userEntity.toString());
    }

    @Test
    public void testGet(){
        Object name = stringRedisTemplate.boundValueOps("name").get();
        System.out.println(name);
    }
}
